/*
    Copyright (C) 2008 Andrew Caudwell (acaudwell@gmail.com)

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version
    3 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LOGENTRY_H
#define LOGENTRY_H

#include <string>
#include <string.h>

#include <vector>
#include <time.h>

#include "core/sdlapp.h"
#include "core/regex.h"

extern bool gMask;

class LogEntry {

private:
    bool parse_ok;

    std::string status_hit;
    std::string request_from_ip;
    std::string request_to_ip;
    std::string request_url;
	long timestamp;
	std::string response_content_type;
	int  response_code;
	long response_bytes;
	std::string response_bytess;

    int parse(std::string& line);
    std::string maskHostname(std::string hostname);

public:

    std::string dump_status;
    std::string dump_time;
    std::string dump_request;
    std::string dump_ip;
    std::string dump_url;
    std::string dump_content;

    LogEntry();
    LogEntry(std::string& entry);

    int         responseCode();
    long        responseBytes();
    std::string responseBytesS();
    long        getTimestamp();

    std::string responseContentType();
    std::string requestURL();
    std::string requestFromIp();
    std::string requestToIp();

    bool successful();

    bool parsedOK();

};

#endif
